// miniprogram/pages/qy_pubjob/pubjob.js
Page({
  onJobSub: function(event){
    const that=this;
   // const about=event.detail.value.about;
    const jobname=event.detail.value.jobname;
    const joblocation=event.detail.value.joblocation;
    const salary=event.detail.value.salary;
    const need=event.detail.value.need;
    const desc=event.detail.value.desc;
    const showtime=event.detail.value.showtime;
    const other=event.detail.value.other;
    wx.showLoading({
      title:'发布中...'
    })
    this.setData({isFabu: true})
    wx.cloud.callFunction({
      name: 'pubJob',
      data: {
        //about: about,
        jobname: jobname,
        joblocation: joblocation,
        salary: salary,
        need: need,
        desc: desc,
        showtime: showtime,
        other: other,
        belong: that.data.zh
      },
      success:result=>{
        const _id=result.result._id;
        if(_id){
          wx.hideLoading();
          wx.showToast({
            icon: 'success',
            title: '发布成功! '
          });
          setTimeout(function(){
            wx.navigateBack({})
          },1000)
        }else{
          wx.showToast({
            title:'失败'
          })
        }
      }
       
    })
    
  },
  /**
   * 页面的初始数据
   */
  data: {
    zh: '',
    isFabu: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   if(options.zh){
    this.setData({
      zh: options.zh
    })
  }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})